package edu.utexas.mapreduce;

import java.net.URL;
import java.util.ArrayList;
import java.util.List;

public class ReduceTask extends Task {

	private List<URL> mapResults;
	
	ReduceTask(int id) {
		super(id);
		this.mapResults = new ArrayList<URL>();
	}
	
	static int getKeyID(String key) {
		final int R = Constants.NUMBER_OF_REDUCE_TASKS;
		return ((key.hashCode() % R) + R) % R;
	}
	
	List<URL> getMapResults() {
		return mapResults;
	}
	
	void addMapResults(URL url) {
		mapResults.add(url);
	}
	
	void clearMapResults() {
		mapResults.clear();
	}
	
	void clear() {
		setOwner("");
		setState(TaskState.IDLE);
		mapResults.clear();
	}
}
